//
//  MSDetailViewController.m
//  MSJD
//
//  Created by xiangbo on 2018/9/28.
//  Copyright © 2018 xiangbo. All rights reserved.
//

#import "MSDetailViewController.h"
#import "MSFoodDetailViewSource.h"

//#import "MSFoodDetailView.h"

@interface MSDetailViewController ()

@property (nonatomic, strong)MSFoodDetailViewSource *detailViewSource;

//@property (nonatomic, strong) MSFoodContentModel *data;

@end

@implementation MSDetailViewController

+ (instancetype)loadDetailViewController:(MSFoodContentModel *)foodData {
    MSDetailViewController *detailVC = [[MSDetailViewController alloc] init];
//    detailVC.data = foodData;
    detailVC.detailViewSource.data = foodData;
    return detailVC;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:self.detailViewSource.pageView];
    [self.detailViewSource.pageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    [self.detailViewSource refreshPageData];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    // 返回按钮
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(backButtonClick)];
    
//    MSFoodDetailView *detailView = [[MSFoodDetailView alloc] init];
//    [self.view addSubview:detailView];
//    [detailView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.left.bottom.right.offset(0);
//    }];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
}

#pragma mark -Property
- (MSFoodDetailViewSource *)detailViewSource{
    if (!_detailViewSource) {
        _detailViewSource = [[MSFoodDetailViewSource alloc] init];
    }
    return _detailViewSource;
}

#pragma mark - Event Response

- (void)backButtonClick {
    [self.navigationController popViewControllerAnimated:YES];
}

@end
